
#delimit ;
 
log using Lemieux_et_al_Mean_Earnings, replace text;
 
u psid7899_mar08;



keep if status==1;
gen unemployed=status==3;
gen unemployed2=status==2 | status==3;

drop if year==98 & tenure<1;

drop if collbarg==.;


replace comm=comm==1 | (commis>0 & commis~=.) | piece==1;
replace boni= (bonus>0 & bonus~=.) | comm==1;
egen maxbon=max(boni), by(jobmatch); /* create bonus job dummy */

gen educ_bonus=(maxbon==1)*educ; /* interaction of education with
                                      bonus job dummy) */

replace avhrly=(avhrly/cpi)*100;
replace hdlaby=(hdlaby/cpi)*100;

drop if avhrly<1.5 | avhrly>100;

gen lw=log(avhrly);


gen type=1 if maxbon==0;
replace type=2 if maxbon==1;

*summ boni comm [aw=iweight];

sort type;

*bys type year: summ salary boni salary_only hourly unemployed unemployed2 hourly_only avhrly educ hours tenure 
*married collbarg nonwhite potexp hdlaby [aw=iweight];

*by type: summ salary boni salary_only hourly unemployed unemployed2 hourly_only avhrly educ hours tenure 
*married collbarg nonwhite potexp hdlaby [aw=iweight];

*summ salary boni salary_only hourly unemployed unemployed2 hourly_only avhrly educ hours tenure 
*married collbarg nonwhite potexp hdlaby [aw=iweight];

by type: summ hdlaby [aw=iweight];

by type: summ hdlaby [aw=iweight] if year == 98;

log close;
clear;
 
